package com.mail.transfer.email;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;

/**
 * @author xiaocg
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class SendDto {
    private Integer tailTag;
    private byte[] data;
    private String message;

    public byte[] toByteArray() {
        ByteBuf buf = Unpooled.buffer(32);
        buf.writeInt(getTailTag());
        buf.writeCharSequence(getMessage(), StandardCharsets.UTF_8);
        buf.writeBytes(getData());
        return buf.array();
    }

}
